/**
 * Created by wenchuan on 2018/11/30.
 */
var debug = true,
    js_verison = '1.0',//加载全局js版本号
    js_verison_ = js_verison + '.5',//加载全局js版本号
    win = window,
    g_obj = {},
    staticPath = location.origin + '/' + location.pathname.split('/')[1] + '/'
;

var appOps = {
    debug: debug,
    html_version: js_verison_,
    css_version: js_verison_,
    appName: 'sanmu',
    openPagePattern:'tab'
};

var _locale = localStorage.getItem("e4j_locale") ? localStorage.getItem("e4j_locale") : 'zh-CN';

//elementUi配置
var _elementConfig = {
    ui_size: 'small'
};
//layUi配置
var _layuiConfig = {
    ui_size: 'sm'
};

require.config({
    baseUrl: staticPath + 'js',
    waitSeconds: 0,
    scriptType: 'text/javascript',
    urlArgs: function (id, url) {
        var _v = js_verison;
        switch (id.split('/')[0]) {
            case 'pc':
                _v = js_verison_;
                break;
        }
        return (url.indexOf('?') === -1 ? '?' : '&') + 'v=' + _v;
    },
    paths: {
        'pc': 'pc',
        'plugins': 'plugins',
        'locale': 'pc/locale/' + _locale,
        'vue': 'plugins/vue.min',
        'math': 'plugins/math.scale',
        'jquery': 'plugins/jquery.min',
        'jquery.storageapi': 'plugins/jquery.storageapi.min',
        'layui': 'plugins/layui/layui',
        'layuiall': 'plugins/layui/layui.all',
        'ELEMENT': 'plugins/element-ui/element-ui2.4.11',
        'element/locale/zh-CN': 'plugins/element-ui/locale/zh-CN.min',
        'echarts': 'plugins/echarts/echarts.min',
        'ecStat': 'plugins/echarts-start/ecStat.min',
        'lodop': 'plugins/lodop/LodopFuncs',
        'nzh':'plugins/nzh.min',
        'amap': 'https://webapi.amap.com/maps?v=1.4.15&key=41aea0d8d312ce810738839aabc8392b&callback=onAMapLoaded',
        'initAMAP':'plugins/initAMAP',
        'viewer': 'plugins/viewer.min'
    }
});

var jss = ["jquery", "ELEMENT", 'layui','math','viewer'];

// if (parent.app) {
//     win.app = parent.app;
//     app.initSys(win);
//     win.E4jlocale = parent.E4jlocale;
// } else {
    jss.push('pc/public/app.min', 'locale');//locale会在app.js里面使用 TODO


// }

window.onAMapLoaded = function() {
    require(['initAMAP'], function(mapIniter) {
        mapIniter.init();
    })
};

require(jss, function ($) {

    win.Vue = require('vue');
    win.elementUi = require('ELEMENT');
    win.Viewer = require('viewer');
    win.Vue.use(elementUi, {size: _elementConfig.ui_size});

    layui.config({
        base: 'js/pc/', //静态资源所在路径
        version: '2.4.5',
        size: _layuiConfig.ui_size
    });

    win.app.datas_ = parent.app.datas_;
    win.app.fields_ = parent.app.fields_;

    if (pageConfig) {
        if (pageConfig.jss) {
            require(pageConfig.jss, function () {
                win.MODULECLASS && MODULECLASS._updateTheme();
            });
        }

        if (pageConfig.cb) {
            pageConfig.cb();
        }
    }

});

